﻿function newXMLHttpRequest() {
  var xmlreq = false;
  if (window.XMLHttpRequest) { 
    xmlreq = new XMLHttpRequest();
  } else if (window.ActiveXObject) {    
    try {
      // 尝试按新版InternetExplorer方法创建
      xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e1) {   
      try {
        xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
     
      }
    }
  }
  return xmlreq;
}
function doPost(group) { 
  var req = newXMLHttpRequest();
  req.onreadystatechange = getReadyStateHandler(req);   
  req.open("POST", "/address.do?parameter=choice&&group="+group, true); 
  req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  req.send("");
}
function getReadyStateHandler(req) { 
  return function () {
    // 如果请求的状态是“完成”
    if (req.readyState == 4) {
      // 检查是否成功接收了服务器响应
      if (req.status == 200) {
        // 将载有响应信息的XML传递到处理函数
		var objXMLDoc=new ActiveXObject("Microsoft.XMLDOM");	
        objXMLDoc.loadXML(req.responseText);
		//<root><address name='' email=''/></root>
		var data=objXMLDoc.selectNodes("//root/address");
		EditForm.allSelect.options.length=0;
		for(var i=0;i<data.length;i++)
		{
		var op=new Option(data[i].getAttribute("name"),data[i].getAttribute("name")+"<"+data[i].getAttribute

("email")+">");
		EditForm.allSelect.options[i]=op;
		}
      } else {
        // 有HTTP问题发生
        alert("HTTP error: "+req.status);
      }
    }
  }